<?php
$bottom_margin = $_MODULE[bottom_margin];
$bottom_color = $_MODULE[bottom_color];
if (!isset($bottom_margin)) $bottom_margin = 0;
if (!isset($bottom_color)) $bottom_color = "#FFFFFF";

$main_title_default = 'main title';
$sub_title_default = 'sub title';
$main_title_color_default = '#FF7F00';
$sub_title_color_default = '#FF7F00';

function getParam($paramName, $defaultValue)
{
    global $_MODULE;
    $value = $_MODULE[$paramName];
    if (empty($value)) return $defaultValue;
    return $value;
}

function myEcho($paramName, $defaultValue)
{
    echo getParam($paramName, $defaultValue);
}

function echoTitleColor($paramName)
{
    echo getParam($paramName, '#CDAA7D');
}

function echoMainTitle($paramName)
{
    echo getParam($paramName, '主标题1');
}

function echoSubTitle($paramName)
{
    echo getParam($paramName, '副标题1');
}

function getIsShow($paramName){
    $param =  getParam($paramName,null);
    if(empty($param)){
        return 'noShow';
    }
    return '';
}


function getCommonImageHtml($link_url_, $image_1, $image_0, $main_title, $sub_title, $main_title_color, $sub_title_color, $i, $marginTop, $paddingLeft,$isShow)
{
    return "

            <td style='$paddingLeft padding-top: $marginTop;'>
                <a $link_url_ target='_blank' class='no_decoration'>
                    <div class='positive_bg_img_$i'
                         style='background-image:url($image_1);'>
                        <div class='title'>
                            <p class='main_title'
                               style='color: $main_title_color;'>$main_title</p>
                            <p class='sub_title'
                               style='color: $sub_title_color;'>$sub_title</p>
                        </div>
                        <div class='reverse_bg_img_$i $isShow'
                             style='background-image:url($image_0);'>
                            <div class='title'>
                                <p class='main_title'
                                   style='color: $main_title_color;'>$main_title</p>
                                <p class='sub_title'
                                   style='color: $sub_title_color;'>$sub_title</p>
                            </div>
                        </div>
                    </div>
                </a>
            </td>
";
}

?>

<div class="module dshop-um-ggw4 module-thirdparty"
     style='margin-bottom:<? echo $bottom_margin; ?>px; background-color:<? echo $bottom_color; ?>;'>
    <table>
        <?php
        $NumberMap = array(0 => 'one', 1 => 'two', 2 => 'three', 3 => 'four', 4 => 'five', 5 => 'six');
        $num = 0;
        for ($i = 0; $i < 2; $i++) {
            echo "<tr>";
            for ($j = 0; $j < 3; $j++) {
                $paddingLeft = '';
                if ($j != 2) $paddingLeft = 'padding-right: 15px;';
                echo getCommonImageHtml(getHref('right_' . $NumberMap[$num] . '_link'),
                    getParam('right_' . $NumberMap[$num] . '_image_1', 'assets/images/right_one_1.jpg'),
                    getParam('right_' . $NumberMap[$num] . '_image_0', 'assets/images/right_one_0.png')
                    , getParam('right_' . $NumberMap[$num] . '_main_title', $main_title_default),
                    getParam('right_' . $NumberMap[$num] . '_sub_title', $main_title_default),
                    getParam('right_' . $NumberMap[$num] . '_main_title_color', $main_title_color_default),
                    getParam('right_' . $NumberMap[$num] . '_sub_title_color', $sub_title_color_default),
                    $i, ($i * 15) . 'px', $paddingLeft,getIsShow('right_' . $NumberMap[$num] . '_image_0'));
                $num++;
            }
            echo "</tr>";
        }
        ?>

    </table>
</div>
